import * as types from "../mutation-types";
import routeService from "../../services/route";
// initial state
const state = {
  provinceSelect: [],
  siteList: [],
  allCarList: [],
  allLineList: [],
}


// getters
const getters = {}


// actions
const actions = {
  loadProvinceSelect ({commit},params) {
    routeService.loadProvinceAndCitySelect(params,function (data) {
      commit(types.LOAD_PROVINCE_SELECT, data);
    });
  },
  loadSiteList ({commit}, params) {
    routeService.loadAllSiteList (params, function (data) {
      commit(types.LOAD_SITE_LIST, data);
    })
  },
  loadAllCars({commit}, params) {
    routeService.loadAllCarList(params, function (data) {
      commit(types.LOAD_All_CAR_LIST, data);
    })
  },
  loadAllLines({commit},params) {
    routeService.loadAllLineList(params,function(data){
      commit(types.LOAD_All_Line_LIST, data);
    })
  }
}


// mutations
const mutations = {
  [types.LOAD_PROVINCE_SELECT] (state, data) {
    state.provinceSelect = data.data;
  },
  [types.LOAD_SITE_LIST] (state, data) {
    state.siteList = data.data;
  },
  [types.LOAD_All_CAR_LIST] (state, data) {
    state.allCarList = data.data;
  },
  [types.LOAD_All_Line_LIST] (state, data) {
    state.allLineList = data.data;
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
